home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1998 July / EnigmA AMIGA RUN 29 (1998)(G.R. Edizioni)(IT)[!][issue 1998-07 & 08].iso / earkit / news / thor / rexx / quotepercent.thor < prev    next >
Text File  |  1998-05-24  |  2KB  |  75 lines

  1. /* QuotePercent.thor by Troels Walsted Hansen
  2. ** $VER: QoutePercent.thor 1.0 (9.1.95)
  3. **
  4. ** Se below for details of what this script does. This script
  5. ** is a port of a script named QuotePercent for Spot by Kent Hansen (se below).
  6. */
  7.  
  8. /*******************************************************************/
  9. /*              QuotePercent v1.0 calculator for Spot              */
  10. /*                    written: May 22th 1994 by                    */
  11. /*               Kent Hansen  (2:230/418.31@FIDONET)               */
  12. /*                e-mail: kent.hansen@scala.pink.dk                */
  13. /*                                                                 */
  14. /* This script calculates the percentage of quoted characters in a */
  15. /* message, and put up a requester showing the percentage          */
  16. /*******************************************************************/
  17.  
  18. options results
  19. signal on syntax
  20.  
  21. /* needs THOR functions */
  22.  
  23. p = ' ' || address() || ' ' || show('P',,)
  24. thorport = pos(' THOR.',p)
  25.  
  26. if thorport > 0 then thorport = word(substr(p,thorport+1),1)
  27. else
  28. do
  29.     say 'No THOR port found!'
  30.     exit 10
  31. end
  32.  
  33. /* start of action */
  34.  
  35. address(thorport)
  36.  
  37. LOCKGUI
  38.  
  39. SAVEMESSAGE FILE 'T:Thor_1.tmp' CURRENT NOHEADER NOANSI
  40. if(rc ~= 0) then
  41. do
  42.     REQUESTNOTIFY TEXT '"'THOR.LASTERROR'"' BT '"_Ok"'
  43.     signal exit
  44. end
  45.  
  46. /* Check for quoted and new characters, skip the tagline */
  47.  
  48. call open('infile', 'T:Thor_1.tmp', R)
  49. quoted = 0; new = 0;
  50.  
  51. currentline = readln('infile')
  52. do while ~eof('infile') & ~(left(currentline,4) = '... ')
  53.     if(right(word(currentline,1),1) = '>' | left(currentline,1) = '>') then quoted = quoted+length(currentline)
  54.     else new = new+length(currentline)
  55.     currentline = readln('infile')
  56. end
  57. call close('infile')
  58.  
  59. proc = trunc((quoted/(new+quoted))*10000)/100
  60.  
  61. /* Put up requester */
  62.  
  63. REQUESTNOTIFY TEXT '"' || 'This message contains ' || proc || '%% of qouted text.' || '"' BT '"_Ok"'
  64.  
  65. /* Cleanup */
  66. address command 'delete T:Thor_1.tmp quiet'
  67. signal exit
  68.  
  69. syntax:
  70.     say rc errortext(rc) 'in line' SIGL
  71. failure:
  72. exit:
  73.     UNLOCKGUI
  74.     exit
  75.